package com.mryan.rabbitmq_springboot.topic;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @description：TODO
 * @Author MRyan
 * @Date 2020/11/23 16:19
 * @Version 1.0
 */
@Component
public class TopicCustomer {

    @RabbitListener(bindings = {
            @QueueBinding(value = @Queue,
                    exchange = @Exchange(name = "topics", type = "topic"),
                    key = {"user.save", "user.*"})
    })
    public void receive1(String message) {
        System.out.println("Message1= " + message);
    }


    @RabbitListener(bindings = {
            @QueueBinding(value = @Queue,
                    exchange = @Exchange(name = "topics", type = "topic"),
                    key = {"order.#", "user.*"})
    })
    public void receive2(String message) {
        System.out.println("Message2= " + message);
    }
}
